package com.briup.mt.web.controller;

import com.briup.mt.bean.Dataset;
import com.briup.mt.service.IDatasetService;
import com.briup.mt.utils.Message;
import com.briup.mt.utils.MessageUtil;
import com.briup.mt.bean.Dataset;
import com.briup.mt.service.IDatasetService;
import com.briup.mt.utils.Message;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * @program: app03
 * @description: 用户控制器类
 * @author: charles
 * @create: 2020-12-15 16:58
 **/
@RestController
@Validated
@RequestMapping("/dataset")


public class DatasetController {

    @Autowired
    private IDatasetService datasetService;

    @GetMapping("query")
    public Message query(String name){
        List<Dataset> list =  datasetService.query(name);
        return MessageUtil.success(list);
    }

    @PostMapping("saveOrUpdate")
    public Message saveOrUpdate(Dataset info){
        datasetService.saveOrUpdate(info);
        return MessageUtil.success("操作成功");
    }

    @DeleteMapping("deleteById")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "用户编号", required = true, paramType = "query"),
    })
    public Message deleteById( @NotNull Long id){
        datasetService.deleteById(id);
        return MessageUtil.success("操作成功");
    }

}
